<template>
  <div class="card">
    <el-card class="box-card u-flex-center u-col-start">
      <el-form inline>
        <el-form-item label="默认全局配送费" prop="default_distribution_fee">
          <el-input
            v-model="params.default_distribution_fee"
            size="mini"
            maxlength="30"
            type="number"
            placeholder="请输入"
          >
          </el-input>
        </el-form-item>
        <el-form-item label="满足包邮订单金额" prop="no_distribution_money">
          <el-input
            v-model="params.no_distribution_money"
            size="mini"
            maxlength="30"
            type="number"
            placeholder="请输入包邮金额"
          >
          </el-input>
        </el-form-item>
      </el-form>
      <div class="card-setup">
        <el-button type="text" size="mini" @click="configChange"
          >保存</el-button
        >
      </div>
    </el-card>
    <el-card
      class="box-card"
      v-for="(item, index) in list"
      :key="index"
      :body-style="{ padding: '0' }"
    >
      <div class="card-main">
        <div class="title">{{ item.scheme_name }}</div>
        <div class="li">
          <span style="font-size: 12px; font-weight: 600">配送费：</span
          >{{ item.fee }}
        </div>
        <div class="li">
          <span style="font-size: 12px; font-weight: 600">创建于：</span
          >{{ item.create_time }}
        </div>
        <div class="li">
          <span style="font-size: 12px; font-weight: 600">编辑于：</span
          >{{ item.update_time }}
        </div>
      </div>
      <div class="card-button u-flex-end">
        <el-button
          type="text"
          size="mini"
          @click="$emit('edit', item.scheme_id)"
          >编辑</el-button
        >
        <el-button
          type="text"
          size="mini"
          @click="$emit('delete', item.scheme_id)"
          >删除</el-button
        >
      </div>
    </el-card>
  </div>
</template>

<script>
export default {
  data() {
    return {
      params: {
        default_distribution_fee: "",
        no_distribution_money: "",
      },
    }
  },
  props: {
    list: {
      type: Array,
      default: () => [],
    },
    tableInfo: {
      type: Object,
      default: () => {},
    },
  },
  watch: {
    tableInfo: {
      handler(newVal) {
        this.params = newVal
      },
      deep: true, // 开启深度监听
    },
  },
  methods: {
    configChange() {
      this.$emit("configChange", this.params)
    },
  },
}
</script>

<style lang="scss" scoped>
.card {
  margin-top: 20px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-row-gap: 20px;
  grid-column-gap: 20px;

  .el-form-item {
    margin: 0 !important;
  }
  .box-card {
    position: relative;
  }

  .card-main {
    padding: 10px;
    border-bottom: 1px solid #f3f3f3;
    .title {
      font-size: 14px;
      font-weight: 600;
    }
    .li {
      color: #000000;
      padding-top: 10px;
    }
  }
  .card-button {
    padding: 0 10px;
    box-sizing: border-box;
  }

  .card-setup {
    position: absolute;
    right: 10px;
    bottom: 0;
  }
}
</style>
